# -*- encoding=utf8 -*-
        
__author__ = "Bryan.Chen"
__desc__=""
        
from airtest.core.api import *
        
auto_setup(__file__)
        
from poco.drivers.std import StdPoco
poco = StdPoco()
        
using("../FlowTest.air")
import FlowTest

using("../mahjong/MahjongTable.air")
import MahjongTable
        
class Club_PlayGame(FlowTest.BaseTestCase):
    def __init__(self):
        print("%s __init__" % (__file__))
        
    def runTest(self, args):
        print("%s runTest" % (__file__))

        isTimeOut = False
        time1 = time.time()
        clubPageLayer = poco("ClubPageLayer")
        while not clubPageLayer.exists():
            clubPageLayer = poco("ClubPageLayer")
            if time.time() - time1 > 1 * 60:
                isTimeOut = True
                break

        if isTimeOut:
            return False


        btnQuickJoin = clubPageLayer.offspring("btn_quick_join")
        assert_equal(btnQuickJoin.exists(), True, "进入俱乐部成功")

        if not btnQuickJoin.exists():
            # 未进入到俱乐部，返回
            return True

        self.clickButton(btnQuickJoin)

        poco("TableScene").wait_for_appearance()

        tableScene = poco("TableScene")

        assert_equal(tableScene.exists(), True, "快速匹配成功")

        MahjongTable.runTest({})

        return True
        
_instance = Club_PlayGame()
runTest = _instance.runTest
